<extend name="Public:base" />
<block name="content">
	<div class="page-header">
		<h1>
			{$breadcrumb2}
			<small>
				<i class="icon-double-angle-right"></i>
				{$crumbs}
			</small>
		</h1>
	</div>	
	<ul class="nav nav-tabs">
		
	  <li class="active"><a href="#tab-order" data-toggle="tab">订单详情</a></li>
	 
	  <!--<li><a href="#tab-shipping" data-toggle="tab">收货地址</a></li>
	 
	  <li><a href="#tab-product" data-toggle="tab">商品清单</a></li>-->
	  
	  <!--<li><a href="#tab-history" data-toggle="tab">订单历史</a></li>-->
	  
	</ul>
	<div class="tab-content">
		<div class="tab-pane active" id="tab-order">
			<table class="table table-bordered">
                <tr>
                    <td>用户退回快递单号</td>
                    <td>{$data.order.express_id}</td>
                </tr>
                <tr>
                    <td>用户退回快递公司名称</td>
                    <td>{$data.order.express_name}</td>
                </tr>
				<tr>
				    <td>售后单号</td>
				    <td>{$data.order.return_num}</td>
				</tr>
				<tr>
					<td>订单编号</td>
					<?php $w_order_id = $data['order']['order_id'];?>
					<!--<td><a class=""  href='{:U("Order/show_order",array("id"=>$w_order_id))}'>{$data.order.order_num}</a></td>-->
                    <td>{$data.order.order_num}</td>
				</tr>
				<tr>
					<td>会员名称</td>
					<td>{$data.order.user_name}</td>
				</tr>
				<!--<tr>
				    <td>电子邮件</td>
				    <td>{$data.order.email}</td>
				</tr>
				  <tr>
				    <td>联系电话</td>
				    <td>{$data.order.telephone}</td>
				</tr> -->
				<tr>
				    <td>价格</td>
				    <td>
				    	￥{$data.order.price}
				    </td>
				</tr>
				<tr>
					<td>申请日期</td>
					<td>{$data.order.create_time|toDate='Y/m/d H:i:s'}</td>
				</tr>
				<tr>
					<td>商品名称</td>
					<td>{$data.order_product.name}</td>
				</tr>
				<tr>
				    <td>显示状态</td>
				    <td id="order-status">{$data.order.order_status_text}</td>
				</tr>
                <tr>
                    <td>类型</td>
                    <td>
                        <?php if($data['order']['type'] == '1'){
                            echo '退货退款';
                        }else{
                            echo '换货';
                        }?>
                    </td>
                </tr>
                <tr>
                    <td>申请理由</td>
                    <td>{$data.order.tuihuo_case}</td>
                </tr>
				<tr>
					<td>退换货描述</td>
					<td>{$data.order.tuihuo_case}</td>
				</tr>
				<tr>
					<td>用户上传图片</td>
					<td>
						<volist name="data.order.voucher" id="v">
							<a href="Uploads/image/{$v}" target="_blank">
								<img src="Uploads/image/{$v}" width="100" height="100">
							</a>
						</volist>
					</td>
					<!--<td id="order-status">{$data.order.tuihuo_case}</td>-->
				</tr>
				<tr>
					<td>操作状态</td>
					<td>
						<select id="status">
							<option value="0">-选择状态-</option>
							<!--<option value="7" <if condition="$data['order']['status'] eq 7">selected</if>>待审核</option>-->
                            <if condition="$data['order']['status'] eq 7">
                                    <option value="8" <if condition="$data['order']['status'] eq 8">selected</if>>审核不通过</option>
                                    <option value="9" <if condition="$data['order']['status'] eq 9">selected</if>>审核通过</option>
                                <elseif condition="$data['order']['status'] eq 8"/>
                                    <option value="8" <if condition="$data['order']['status'] eq 8">selected</if>>审核不通过</option>
                                <elseif condition="$data['order']['status'] eq 9"/>
                                    <option value="9" <if condition="$data['order']['status'] eq 9">selected</if>>审核通过</option>
                                    <option value="12" <if condition="$data['order']['status'] eq 12">selected</if>>
                                        <?php
                                        if($data['order']['type'] == 1){
                                            echo '确认退款';
                                        }else{
                                            echo '确认换货';
                                        }
                                    ?>
                                    </option>
                                <elseif condition="$data['order']['status'] eq 12"/>
                                    <option value="12" <if condition="$data['order']['status'] eq 12">selected</if>>
                                        <?php
                                        if($data['order']['type'] == 1){
                                            echo '确认退款';
                                        }else{
                                            echo '确认换货';
                                        }
                                    ?></option>
                            </if>
						</select>
					</td>
				</tr>
                <if condition="$data['order']['type'] eq 2">
                    <if condition="$data['order']['express_id'] neq ''">
                        <tr>
                            <td>壹贰寄出快递单号</td>
                            <td>
                                <input type="text" id="express_id_s" value="{$data['order']['express_id_s']}" />
                            </td>
                            <!--<td id="order-status">{$data.order.tuihuo_case}</td>-->
                        </tr>

                            <tr>
                                <td>壹贰寄出快递公司名称</td>
                                <td>
                                    <select id="express">

                                                <option value="{$data['order']['express_name_s']}">
                                                    <?php
                                                    if(!empty($data['order']['express_name_s'])){
                                                        echo $data['order']['express_name_s'];
                                                    }else{
                                                    echo '请选择快递公司';
                                                    }
                                                ?>
                                                </option>

                                        <volist name="express" id="v">
                                            <option value="{$v['name']}">{$v['name']}</option>
                                        </volist>
                                    </select>
                                </td>
                            </tr>
                     </if>
                </if>
                <tr>
                    <td>审核留言</td>
                    <td>
                        <textarea id="messages" name="message" cols="30" rows="4">{$data.order.message}</textarea>
                    </td>
                    <!--<td id="order-status">{$data.order.tuihuo_case}</td>-->
                </tr>
				<!--<tr>
					<td>IP地址</td>
					<td>{$data.order.ip_region}</td>
				</tr>  
				<tr>
					<td>用户系统</td>
					<td>{$data.order.user_agent}</td>
				</tr>-->
				<!--<tr>
					<td>下单时间</td>
					<td>{$data.order.date_added|toDate='Y/m/d H:i:s'}</td>
				</tr>
				<tr>
					<td>修改时间</td>
					<td>{$data.order.date_modified|toDate='Y/m/d H:i:s'}</td>
				</tr>-->
				</table>
            <if condition="$data['order']['status'] neq 12">
                <div class="text-right">
                    <button id="button-history" class="btn btn-primary" data-loading-text="Loading...">
                        <i class="fa fa-plus-circle"></i>
                        保存
                    </button>
                </div>
            </if>
		</div>


		
	</div>
</block>
<block name="javascript">
<script>
$('#button-history').live('click', function() {
	$.ajax({
		url: '<?php echo U("ReturnOrder/audit"); ?>',
		type: 'post',
		dataType: 'html',
		data: {
            "id": "{$data.order.id}",
            "status": $('#status').val(),
            "message": $('#messages').val(),
            "express_id_s": $('#express_id_s').val(),
            "express": $('#express').val(),
        },
		success: function(re) {

            var re=JSON.parse(re)

            if(re.code =='0') {
                alert('请选择操作状态！');
            }

            if(re.code =='1') {
                alert('该售后单已经审核不通过过，请勿再审核！');
            }

            if(re.code =='2') {
                alert('该售后单已经确认退款，请勿再审核！');
            }
            if(re.code =='3') {
                alert('请勿选择同样的状态！');
            }

            if(re.code == '200'){
                alert('审核通过');
            }

            if(re.code =='400') {
                alert('审核失败');
            }
            window.location.reload();
        }
	});
});
</script>
</block>